﻿using MemoryDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MemoryDBTests
{
    internal class TestBase
    {
        public CategoryTable Generate(int count)
        {
            var category = new CategoryTable()
            {
                PrimaryKey = new PrimaryKey<CategoryEntity, int>()
            };

            var rows = new List<CategoryEntity>();
            for (int i = 0; i < count; i++)
            {
                rows.Add(new CategoryEntity { Id = i + 1, Name = "小明" + (i + 1), IsActive = true });
            }
            category.PrimaryKey.Rows = rows;
            category.PrimaryKey.Table = category;
            var sortValues = new List<IndexItem<CategoryEntity, int, int>>();
            for (int i = 0; i < count; i++)
            {
                sortValues.Add(new IndexItem<CategoryEntity, int, int>()
                {
                    Index = category.PrimaryKey,
                    PrimaryIndex = i,
                    Value = i + 1
                });
            }
            category.PrimaryKey.SortedValues = sortValues;
            return category;
        }
    }

    public class CategoryTable : Table<CategoryEntity, int>
    {

    }

    public class CategoryEntity
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public bool IsActive { get; set; }
    }
}
